#!/bin/bash

if [ $# != 1 ]; then
    echo "usage: $0 <unittest file>"
    exit
fi

today=`date +%Y%m%d`
log="./"$today".log"
old_logs=`ls . | grep -v "$log" | wc -l`
if [ $old_logs -gt 0 ]; then
    ls . | grep "\.log" | grep -v "$log" | xargs rm
fi

cat /dev/null > "$log"
cat /dev/null > /home/david/soft/nginx/logs/access.log
cat /dev/null > /home/david/soft/nginx/logs/error.log

phpunit3 "$1"

echo "----- tail access log -------"
tail  /home/david/soft/nginx/logs/access.log
echo "----- tail error log -------"
grep "\[error\]"  /home/david/soft/nginx/logs/error.log | tail
echo "----- tail $log -------"
tail "$log"

